<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>startsWith方法和endsWith方法</title>
</head>

<body>
  <script type="text/javascript">
    let str = 'Hello ECMAScript 2015';
    let r1 = str.startsWith('Hello');
    console.log(r1); //true
    let r2 = str.endsWith('2016');
    console.log(r2) //false
  </script>
</body>

</html>